From 70d89764e3daca7760e3dbe94a0ad241ffbe3586 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Sun, 30 Nov 2025 20:03:03 +0100 Subject: [PATCH] luci-mod-network,-status: expose the lease interface MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This adds support to LuCI for showing the interface which a given lease corresponds to (assuming that odhcpd is providing the DHCPv4/6 services, which the code also checks for). Signed-off-by: David Härdeman --- .../luci-static/resources/view/network/dhcp.js | 16 ++++++++++++++-- .../resources/view/status/include/40_dhcp.js | 8 ++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 3ed5999f3b..e4ae4567eb 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -39,6 +39,7 @@ const CBILeaseStatus = form.DummyValue.extend({ E('h4', _('Active DHCPv4 Leases')), E('table', { 'id': 'lease_status_table', 'class': 'table' }, [ E('tr', { 'class': 'tr table-titles' }, [ + L.hasSystemFeature('odhcpd', 'dhcpv4') ? E('th', { 'class': 'th' }, _('Interface')) : E([]), E('th', { 'class': 'th' }, _('Hostname')), E('th', { 'class': 'th' }, _('IPv4 address')), E('th', { 'class': 'th' }, _('MAC address')), @@ -58,6 +59,7 @@ const CBILease6Status = form.DummyValue.extend({ E('h4', _('Active DHCPv6 Leases')), E('table', { 'id': 'lease6_status_table', 'class': 'table' }, [ E('tr', { 'class': 'tr table-titles' }, [ + L.hasSystemFeature('odhcpd', 'dhcpv6') ? E('th', { 'class': 'th' }, _('Interface')) : E([]), E('th', { 'class': 'th' }, _('Hostname')), E('th', { 'class': 'th' }, _('IPv6 addresses')), E('th', { 'class': 'th' }, _('DUID')), @@ -249,12 +251,17 @@ return view.extend({ else if (lease.hostname) host = lease.hostname; - return [ + const columns = [ host || '-', lease.ipaddr, vendor ? lease.macaddr + vendor : lease.macaddr, exp ]; + + if (L.hasSystemFeature('odhcpd', 'dhcpv4')) + columns.unshift(lease.interface || '-'); + + return columns; }), E('em', _('There are no active leases')) ); @@ -281,13 +288,18 @@ return view.extend({ else if (name) host = name; - return [ + const columns = [ host || '-', lease.ip6addrs ? lease.ip6addrs.join('
') : lease.ip6addr, lease.duid, lease.iaid, exp ]; + + if (L.hasSystemFeature('odhcpd', 'dhcpv6')) + columns.unshift(lease.interface || '-'); + + return columns; }), E('em', _('There are no active leases')) ); diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js index abd2476eaa..3cbc0c31ae 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js @@ -106,6 +106,7 @@ return baseclass.extend({ const table = E('table', { 'id': 'status_leases', 'class': 'table lases' }, [ E('tr', { 'class': 'tr table-titles' }, [ + L.hasSystemFeature('odhcpd', 'dhcpv4') ? E('th', { 'class': 'th' }, _('Interface')) : E([]), E('th', { 'class': 'th' }, _('Hostname')), E('th', { 'class': 'th' }, _('IPv4 address')), E('th', { 'class': 'th' }, _('MAC address')), @@ -145,6 +146,9 @@ return baseclass.extend({ exp, ]; + if (L.hasSystemFeature('odhcpd', 'dhcpv4')) + columns.unshift(lease.interface || '-'); + if (!isReadonlyView && lease.macaddr != null) { columns.push(E('button', { 'class': 'cbi-button cbi-button-apply', @@ -159,6 +163,7 @@ return baseclass.extend({ const table6 = E('table', { 'id': 'status_leases6', 'class': 'table leases6' }, [ E('tr', { 'class': 'tr table-titles' }, [ + L.hasSystemFeature('odhcpd', 'dhcpv6') ? E('th', { 'class': 'th' }, _('Interface')) : E([]), E('th', { 'class': 'th' }, _('Host')), E('th', { 'class': 'th' }, _('IPv6 addresses')), E('th', { 'class': 'th' }, _('DUID')), @@ -208,6 +213,9 @@ return baseclass.extend({ exp ]; + if (L.hasSystemFeature('odhcpd', 'dhcpv6')) + columns.unshift(lease.interface || '-'); + if (!isReadonlyView && lease.duid) { columns.push(E('button', { 'class': 'cbi-button cbi-button-apply', -- 2.30.2